/// An exception class for handling errors in the CompactDio library.
class CompactDioException implements Exception {
  final String? _message;
  final int? _statusCode;

  /// Creates a new instance of [CompactDioException].
  ///
  /// The [statusCode] and [message] parameters are optional.
  CompactDioException([this._statusCode, this._message]);

  /// The error message associated with the exception.
  ///
  /// If no message is provided, the default message '请求错误' will be used.
  String get message => _message ?? '请求错误';

  /// The HTTP status code associated with the exception.
  ///
  /// If no status code is provided, the default value of -1 will be used.
  int get statusCode => _statusCode ?? -1;

  @override
  String toString() {
    return 'CompactDioException{message: $_message, statusCode: $_statusCode}';
  }
}
